import cookies from "vue-cookies";
const public_key_id = "public_key";
const userKey = "userKey"
    // 设置AccessToken 时限为1天
export const setAccessToken = (token) => {
    cookies.set("accessToken", "Bearer " + token, {
        expires: 1,
        httpOnly: true,
    });
};
export const getAccessToken = () => {
    return cookies.get("accessToken");
};
export const removeAccessToken = () => {
    cookies.remove("accessToken");
};
// 设置RefreshToken
export const setRefreshToken = (token) => {
    cookies.set("RefreshToken", "Bearer " + token, {
        expires: 15,
        httpOnly: true,
    });
};
// 获取refreshToken
export const getRefreshToken = () => {
    return cookies.get("RefreshToken");
};
export const removeRefreshToken = () => {
    cookies.remove("RefreshToken");
};
export const getPublicKey = () => {
    return sessionStorage.getItem(public_key_id);
};
export const setPublicKey = (publicKey) => {
    return sessionStorage.setItem(public_key_id, publicKey);
};
export const removePublicKey = () => {
    return sessionStorage.removeItem(public_key_id);
};
// 用户信息
export const claimUserInfo = () => {
    return JSON.parse(sessionStorage.getItem(userKey));
};
export const setUserInfo = (userInfo) => {
    return sessionStorage.setItem(userKey, JSON.stringify(userInfo));
};
export const removeUserInfo = () => {
    return sessionStorage.removeItem(userKey);
};